<?php
/**
 * 
 * Validation class
 * 
 * @category Abovo
 * 
 * @package Abovo
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 * 
 */

/**
 * 
 * Validation class
 * 
 * Adds some methods to Solar_DataFilter
 * 
 * @category Abovo
 * 
 * @package Abovo
 * 
 */
class Abovo_Model_Auth_DataFilter extends Abovo_DataFilter {
    
    /**
     * 
     * Validates a user handle
     * 
     * Lowercase characters and numbers
     * 
     * @param string $value Value to validate
     * 
     * @return bool
     * 
     */
    public function validateHandle($value)
    {
        if (! $this->_require && $this->validateBlank($value)) {
            return null;
        }
        
        $regex = "/^([a-z0-9]{5,15}+)\$/D";
        return $this->validateRegex($value, $regex);
    }
    
    /**
     * 
     * Validates a password
     * 
     * Basically just 5-15 chars long, no whitespaces.
     * 
     * @param string $value Value to validate
     *
     * @return bool
     * 
     */
    public function validatePasswd($value)
    {
        if (! $this->_require && $this->validateBlank($value)) {
            return null;
        }
        
        return $this->validateRangeLength($value, 5, 15);
    }
    
}